<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>添加工单实际工器具</title>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
    <style type="text/css">
        .detail {
            padding-right: 20px!important;
        }

        h5,
        label {
            color: #0062CC;
        }

        label {
            font-size: 14px;
        }

        .mui-navigate-right .mui-col-xs-8 {
            width: 62.666667%!important;
        }

        .mui-text-right input,
        .mui-text-right textarea {
            border: 0;
            font-size: 14px;
            font-weight: 400;
            color: #8f8f94;
            margin-bottom: 0;
            text-align: right;
        }
    </style>
</head>

<body>
    <div class="mui-content">
        <ul class="mui-table-view mui-table-view-chevron type_list_spair">
            <li class="mui-table-view-cell detail" tapmode onclick="openSaveWin('work_order_sel_tast','选择任务',{wonum: api.pageParam.wonum,linetype: api.pageParam.linetype})">
                <div class="mui-table mui-navigate-right">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">任务：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="refwo">请选择任务</span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail" tapmode onclick="openSaveWin('work_order_sel_tool','选择工具')">
                <div class="mui-table mui-navigate-right">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">工具：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="itemnum">请选择工具</span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">描述：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="toolDescription"></span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">数量：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <input type="number" placeholder="请输入数量" name="" id="toolqty" value="" />
                    </div>
                </div>
            </li>
            <!--<li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">工具小时数：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <input type="number" onchange="linecost()" placeholder="请输入工具小时数" name="" id="toolhrs" value="" />
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">费率：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <input type="number" onchange="linecost()" placeholder="请输入费率" name="" id="toolrate" value="" />
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">行成本：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span id="linecost"></span>
                    </div>
                </div>
            </li>-->
        </ul>
        <ul class="mui-table-view mui-table-view-chevron type_list_spair" tapmode onclick="openSaveWin('work_order_sel_address','选择地址')">
            <li class="mui-table-view-cell detail">
                <div class="mui-table mui-navigate-right">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">位置：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="location">请选择位置</span>
                    </div>
                </div>
            </li>
            <li class="mui-table-view-cell detail">
                <div class="mui-table">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">位置描述：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <span class="mui-h5" id="locationDesc"></span>
                    </div>
                </div>
            </li>
        </ul>
        <ul class="mui-table-view mui-table-view-chevron type_list_spair">
            <li class="mui-table-view-cell detail">
                <div class="mui-table mui-navigate-right">
                    <div class="mui-table-cell mui-col-xs-4">
                        <h5 class="mui-ellipsis">是否外部：</h5>
                    </div>
                    <div class="mui-table-cell mui-col-xs-8 mui-text-right">
                        <select id="outside">
                          <option value="1" selected="true">是</option>
                          <option value="0">否</option>
                        </select>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
  apiready = function () {
    // 选择任务
    api.addEventListener({
		    name: 'TastId'
		}, function(ret, err) {
			$api.html($api.byId('refwo'),ret.value.tastnum)
		});
    // 选择工具
    api.addEventListener({
		    name: 'ToolEvt'
		}, function(ret, err) {
			$api.html($api.byId('itemnum'),ret.value.itemnum)
      $api.html($api.byId('toolDescription'),ret.value.description)
		});
    // 选择位置
    api.addEventListener({
        name: 'LocactionId'
    }, function(ret, err) {
      $api.html($api.byId('location'),ret.value.locationName)
      $api.html($api.byId('locationDesc'),ret.value.Location)
    });
    api.addEventListener({
        name: 'navitembtn'
    }, function(ret, err) {
        if (ret.index == 0) {
            if ($api.html($api.byId('refwo')) == '请选择任务') {
                Toast('请选择任务！');
                return
            }
            if ($api.html($api.byId('itemnum')) == '请选择工具') {
                Toast('请选择工具');
                return
            }
            if ($api.val($api.byId('toolqty')) == '请输入数量') {
                Toast('请输入数量');
                return
            }
//          if ($api.val($api.byId('toolhrs')) == '请输入工具小时数') {
//              Toast('请输入工具小时数');
//              return
//          }
//          if ($api.val($api.byId('toolrate')) == '请输入费率') {
//              Toast('请输入费率');
//              return
//          }
            if ($api.html($api.byId('location')) == '请选择位置') {
                Toast('请选择位置');
                return
            }

            ajaxrd("saveToolTrans", {
                refwo: $api.text($api.byId('refwo')),
                itemnum: $api.text($api.byId('itemnum')),
                toolqty: $api.val($api.byId('toolqty')),
                toolhrs: 0,
                toolrate: 0,
                linecost: 0,
                location: $api.text($api.byId('location')),
                outside:$api.byId('outside').value
            }, function(ret, err) {
                api.sendEvent({
                    name: 'refersh',
                    extra: {
                        isrefersh: 'yes'
                    }
                });
                Toast('添加成功！');
                setTimeout(function() {
                    api.closeWin();
                }, 500)
            })
        } else { //扫码

        }
    });
  }
  var linecost = function () {
    if ($api.val($api.byId('toolrate')) =='' || $api.val($api.byId('toolhrs')) == '') {
      return
    }
    $api.text($api.byId('linecost'),($api.val($api.byId('toolrate')) * $api.val($api.byId('toolhrs'))).toFixed(2))
  }
</script>

</html>
